// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

//引入axios/
import axios from 'axios'
//引入elementUI
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI);

//添加请求拦截器
axios.interceptors.request.use(config=>{
  if(localStorage.getItem("token")){
    config.headers["token"] = localStorage.getItem("token");
  }else{
    config.headers["token"] ="null";
  }
  return config;
});

axios.interceptors.response.use(
  function(config){
    if(config.headers.token){
        localStorage.setItem("token",config.headers.token);
    }
    return config;
  }
);


//设置默认路径
axios.defaults.baseURL = "http://localhost:8099"

//2.将axios绑定到vue的原型对象上
Vue.prototype.$http = axios

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
